#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:chengyanan
@file: register_business.py
@time: 2019/12/21  3:53 下午
"""
import os
import sys
path = os.path.dirname(os.getcwd())
sys.path.append(path)
from handle.register_handle import RegisterHandle
'''
对应的case的farst_case
'''


class RegisterBusiness:
    def __init__(self, driver):
        self.register_h = RegisterHandle(driver)

    def user_base(self, name=None, password=None):
        self.register_h.click_index_loginbtn()
        self.register_h.click_account_login_btn()
        self.register_h.send_user_name(name)
        self.register_h.send_user_password(password)
        self.register_h.click_register_button()

    def register_succes(self):
        if self.register_h.get_register_text()==None:
            return True
        else:
            return False

    # 执行操作
    # name为空
    def login_user_null(self,name,password):
        self.user_base(name,password)
        if self.register_h.get_user_text(info="name_null", user_info="请输入账户名")==None:
            print("检验失败")
        else:
            print('账户名未输入时,检验成功')

    # 密码为空
    def login_password_null(self, name,password):
        self.user_base(name,password)
        if self.register_h.get_user_text(info="password_null", user_info="请输入密码") == None:
            print("检验失败")

            return True
        else:
            print('密码未输入时,检验成功')

            return False

    def login_name_password_null(self,name,password):
        self.user_base(name, password)
        if self.register_h.get_user_text(info="name_and_password_null", user_info="请输入账户名和密码")==None:
            print("检验失败")
            return True
        else:
            print('账户和密码未输入时,检验成功')
            return False

    #数据的驱动方法
    def register_function(self,name,password,assertcode,asserttext):
        self.user_base(name, password)
        if self.register_h.get_user_text(assertcode,asserttext)==None:
            return True
        else:
            return False

